package com.zczy.controller;

import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.zczy.entity.ZczyUser;
import com.zczy.entity.ZczyUserlevel;
import com.zczy.service.ZczyUserService;
import com.zczy.service.ZczyUserlevelService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class UserCenterController {

    @Autowired
    private ZczyUserService zczyUserService;

    @Autowired
    private ZczyUserlevelService zczyUserlevelService;


    // 去个人设置页面
    @GetMapping("/setting/{id}")
    public String setting(@PathVariable("id") Integer id, Model model){

        // 用户个人信息
        ZczyUser user = zczyUserService.getById(id);
        model.addAttribute("user",user);

        //用户等级信息
        List<ZczyUserlevel> zczyUserlevels = zczyUserlevelService.lambdaQuery().eq(ZczyUserlevel::getUser_id, id).list();

        model.addAttribute("zczyUserlevels",zczyUserlevels);
        zczyUserlevels.forEach(System.out::println);


        return "个人设置-剪切上传头像";
    }


}
